﻿<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-timepicker-addon.js" type="text/javascript"></script>

@model PInitiatives.Models.CreateInitiativeModel
@{
    ViewBag.Title = "Nowy ivent";
}

<h3><i class=" icon-star-empty"></i> Nowy ivent</h3>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>
        
        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>
        
        <div class="editor-label">
            @Html.LabelFor(model => model.Limit)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Limit)
            @Html.ValidationMessageFor(model => model.Limit)
        </div>
        
@*        <div class="editor-label">
            @Html.LabelFor(model => model.State)
        </div>
        <div class="editor-field">
            @Html.DropDownList("State")
            @Html.ValidationMessageFor(model => model.State)
        </div>*@
          
        
        <div class="editor-label">
            @Html.LabelFor(model => model.StartDate)
        </div>
      <script type="text/javascript">
          $(document).ready(function () {
              $('.StartDT').datetimepicker({
                  timeFormat: "hh:mm",
                  dateFormat: "yy-mm-dd",
                  minDate: new Date()
                  })
          });
        </script>            
        <div class="editor-field">           
            @Html.TextBox("StartDate", DateTime.Now.AddHours(4).ToString("yyyy-MM-dd HH:00"), new { @class = "StartDT" })
            @Html.ValidationMessageFor(model => model.StartDate)
        </div>

        
        <div class="editor-label">
            @Html.LabelFor(model => model.FreeResignDate)
        </div>
        <script type="text/javascript">
//            var frd = document.getElementById("StartDate").value;
//            var frd1 = frd.substring(0, 4);
//            var frd2 = frd.substring(5, 7) - 1;
//            var frd3 = frd.substring(8, 10);
//            var frd4 = frd.substring(11, 13);
//            var frd5 = frd.substring(14, 16);
          $(document).ready(function () {
              $('.FreeResignDT').datetimepicker({
                  timeFormat: "hh:mm",
                  dateFormat: "yy-mm-dd",
                  minDate: new Date()
                  })
          });
        </script>
            <div class="editor-field">           
            @Html.TextBox("FreeResignDate", DateTime.Now.AddHours(2).ToString("yyyy-MM-dd HH:00"), new { @class = "FreeResignDT" })
            @Html.ValidationMessageFor(model => model.FreeResignDate)
        </div>
        
        
        <div class="editor-label">
            @Html.LabelFor(model => model.Category)
        </div>
        <div class="editor-field">
            @Html.DropDownList("Category")
            @Html.ValidationMessageFor(model => model.Category)
        </div>

        <br>
        <p>
            <input type="submit" value="Utwórz" />
        </p>
    </fieldset>
}

<div style="border-bottom: 1px solid #DDD;"></div>
<br>
<div>
    @Html.ActionLink("Powrót", "Index")
</div>

<script type="text/javascript">
    function conf() {

        var FRDate = document.getElementById("FreeResignDate").value;
        var SDate = document.getElementById("StartDate").value;

        var date = new Date();
        var dateString = date.getFullYear() + '-';
        if (date.getMonth() < 9)
            dateString += '0';
        dateString += (date.getMonth() + 1) + '-';
        if (date.getDate() < 10)
            dateString += '0';
        dateString += date.getDate() + ' ';
        if (date.getHours() < 10)
            dateString += '0';
        dateString += date.getHours() + ':';
        if (date.getMinutes() < 10)
            dateString += '0';
        dateString += date.getMinutes() + ':';
        if (date.getSeconds() < 10)
            dateString += '0';
        dateString += date.getSeconds();

        if (FRDate < dateString) {
            alert("Data iventu nie może być z przeszłości!");
            alert(document.forms[0].elements[1].name);
            return false
        } else
            return true;
        
    }
</script>

<link href="../../Content/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
